﻿namespace X2OPC.Core.DA
{
    using System;
    using System.Runtime.InteropServices;
    [ComImport,InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("39c13a54-011e-11d0-9675-0020afd8adb3"), ComVisible(true)]
    public interface IOPCItemMgt
    {
        /// <summary>
        /// 在OPCGroup内新增OPCItem(s) 
        /// </summary>
        /// <param name="dwCount"></param>
        /// <param name="pItemArray"></param>
        /// <param name="ppAddResults"></param>
        /// <param name="ppErrors"></param>
        /// <returns></returns>
        [PreserveSig]
        int AddItems([In] int dwCount, [In] IntPtr pItemArray, out IntPtr ppAddResults, out IntPtr ppErrors);

        /// <summary>
        /// 检查OPCItem(s)的名称是否可用
        /// </summary>
        /// <param name="dwCount"></param>
        /// <param name="pItemArray"></param>
        /// <param name="bBlobUpdate"></param>
        /// <param name="ppValidationResults"></param>
        /// <param name="ppErrors"></param>
        /// <returns></returns>
        [PreserveSig]
        int ValidateItems([In] int dwCount, [In] IntPtr pItemArray, [In, MarshalAs(UnmanagedType.Bool)] bool bBlobUpdate, out IntPtr ppValidationResults, out IntPtr ppErrors);

        /// <summary>
        /// 移除OPCGroup 內的 OPCItem(s) 
        /// </summary>
        /// <param name="dwCount"></param>
        /// <param name="phServer"></param>
        /// <param name="ppErrors"></param>
        /// <returns></returns>
        [PreserveSig]
        int RemoveItems([In] int dwCount, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] int[] phServer, out IntPtr ppErrors);

        /// <summary>
        /// 高定 OPCItem(s)是否为Avtive 
        /// </summary>
        /// <param name="dwCount"></param>
        /// <param name="phServer"></param>
        /// <param name="bActive"></param>
        /// <param name="ppErrors"></param>
        /// <returns></returns>
        [PreserveSig]
        int SetActiveState([In] int dwCount, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] int[] phServer, [In, MarshalAs(UnmanagedType.Bool)] bool bActive, out IntPtr ppErrors);

        /// <summary>
        /// 设定 OPCItem(s) 的 handle 
        /// </summary>
        /// <param name="dwCount"></param>
        /// <param name="phServer"></param>
        /// <param name="phClient"></param>
        /// <param name="ppErrors"></param>
        /// <returns></returns>
        [PreserveSig]
        int SetClientHandles([In] int dwCount, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] int[] phServer, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] int[] phClient, out IntPtr ppErrors);

        /// <summary>
        /// 设定OPCItem(s)的数据类型 
        /// </summary>
        /// <param name="dwCount"></param>
        /// <param name="phServer"></param>
        /// <param name="pRequestedDatatypes"></param>
        /// <param name="ppErrors"></param>
        /// <returns></returns>
        [PreserveSig]
        int SetDatatypes([In] int dwCount, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] int[] phServer, [In] IntPtr pRequestedDatatypes, out IntPtr ppErrors);

        /// <summary>
        /// 产生OPCItems的列举器 
        /// </summary>
        /// <param name="riid"></param>
        /// <param name="ppUnk"></param>
        /// <returns></returns>
        [PreserveSig]
        int CreateEnumerator([In] ref Guid riid, [MarshalAs(UnmanagedType.IUnknown), Out] out object ppUnk);
    }
}